
import React from 'react';
import './Nav.css'
import { FormPreviousLink } from 'grommet-icons';
import { back } from '../../utils/utils'
export default class Nav extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      content: this.props.content ?? "页面",
      isindex: this.props.isindex ?? false
    }
  }

  toBack = () => {
    if(this.props.content=="唐玮龙"){
      if(window.socket){
        window.socket.sendMessage({
          code: "3",
          receiverId: "twlchat",
          senderId: localStorage.getItem("WsUid"),
        })
      }
    }
    back(window.history,0.1);
  };

  render () {
    return (
      <div className='nav-local'>
         <div className='nav-black-zindex'></div>
        <div className='nav-black'>
          <div className={this.state.isindex ? 'nav-left' : 'nav-left-active'} onClick={this.toBack}>
            {
              !this.state.isindex && "返回"
            }
          </div>
          <div className='nav-content'>{this.state.content}</div>
          <div className='nav-right'></div>
        </div>
      </div>
    );
  }
}
